home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
(A)Z
/
(A)Z7.ADF
/
Execute
/
YesNo
/
yesno.c
< prev
Wrap
C/C++ Source or Header
|
1986-10-31
|
2KB
|
60 lines
/*==========================
amiga/programs #26, from jdow, 1392 chars, Sun Feb 16 16:30:35 1986
--------------------------
TITLE: yesno.c
I found a need in "execute" files to have operator intervention control
the direction a batch file may take. The yesno.c program gives me a
certain amount of control over this. I made little effort to get elegant
as I could see little savings or benefit.
*
*
* yesno.c
*
* Version 1.0 (original release)
*
* Usage:
* yesno "match string" <-c>
* yesno prompts for operator input and compares it to the string.
* if the -c option is present both strings are converted to caps before
* the comparison.
*
* Copyright 14-Feb-86 by Joanne Dow - released for free distribution as
* long as this copyright notice is retained in the file.
*
*/
#include "stdio.h"
#include "ctype.h"
#define NO 6 /* > warn level exit code */
#define YES 0 /* No warning exit code */
#define SIZE 81 /* Size of read buffer */
main(argc, argv)
char *argv[];
{
int caps;
char chxxx[SIZE], *pch;
if (argc <= 1)
{
printf("No arguments\n");
exit(NO); /* exit false */
}
caps = ((argc > 1) && (argv[2][0] == '-') && (argv[2][1]) == 'c');
pch = fgets( &chxxx[0], SIZE, stdin);
chxxx[strlen(pch)-1] = '\0';
if (caps)
{
while (*pch = toupper(*pch)) pch++;
printf("\n");
pch = argv[1];
while (*pch = toupper(*pch)) pch++;
pch = &chxxx[0];
}
if (strcmp(argv[1], pch) == 0) exit(YES);
else exit(NO);
}